package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.qiantu.api.entity.SceneAutoCreateInfo;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;

import java.util.Map;

public class SceneAutoCreateAdapter extends AppAdapter<SceneAutoCreateInfo> {
    public SceneAutoCreateAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public SceneAutoCreateAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new SceneAutoCreateAdapter.ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private final TextView sceneName;
        private final TextView bingingName;
        private final TextView createState;

        private ViewHolder() {
            super(R.layout.panel_qr_binging_item);
            sceneName = findViewById(R.id.key_name);
            bingingName = findViewById(R.id.binging_name);
            createState = findViewById(R.id.binging_state);
        }

        @Override
        public void onBindView(int position) {
            SceneAutoCreateInfo info = getItem(position);
            sceneName.setText(info.getSceneName());
            bingingName.setText("");
            if(info.getState() == 3){
                createState.setText("失败");
            }else if(info.getState() == 1){
                createState.setText("成功");
            }else if(info.getState() == 2){
                createState.setText("生成中");
            }else{
                createState.setText("");
            }
        }
    }
}
